package com.ciwong.epaper.modules.epaper.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.msg.bean.Symbols;
import com.ciwong.epaper.modules.viedoexplantion.util.ViedoJumpManager;

import java.util.List;

public class SymbolGridViewAdapter extends BaseAdapter {

    private Context mContext;

    private List<Symbols> itemGridList;

    public SymbolGridViewAdapter(List<Symbols> itemGridList,Context mContext){
        this.mContext = mContext;
        this.itemGridList = itemGridList;
    }


    @Override
    public int getCount() {
        return itemGridList.size();
    }

    @Override
    public Object getItem(int i) {
        return itemGridList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        if(null == view){
            view = View.inflate(mContext, R.layout.activity_symbol_child,null);
        }
        Button symbol_child = view.findViewById(R.id.symbol_btn_child);
        symbol_child.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               Symbols symbols =  itemGridList.get(i);
                ViedoJumpManager.jumpToSymbolVideo(R.string.go_back, (Activity) mContext,symbols);
            }
        });
        symbol_child.setText("["+itemGridList.get(i).getSymbols()+"]");
        return view;
    }
}
